﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Dialog.Master" AutoEventWireup="true" CodeBehind="SSSDialogBox.aspx.cs" Inherits="Legazpi.Payroll.Web.PopupBoxes.SSSDialogBox" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
    var serviceUrl = '<%=ResolveUrl("~/Webservices/UtilitiesWebsService.asmx")%>';
    $(document).ready(function () {
        $('#SSSSubmitButton').click(function () {
            if (!$("#dialogForm").valid()) {
                return false;
            }    
            var SSSObj = {
                Id: $('#Id').val(),
                StartRange: $('#StartRange').val(),
                EndRange: $('#EndRange').val()
            };
            var json = JSON.stringify({ sssItem: SSSObj });
            BlockUI.BlockElementLoading("dialog", "Saving...", true, 4);
            $.ajax({
                type: "POST",
                url: serviceUrl + "/UpdateSSS",
                data: json,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var response = eval('(' + data.d + ')');
                    if (response.Success) {
                        alert('Saved!');
                        PopUpDialog.CloseDialog(SSS.SSSUpdatePopUpId);
                        SSS.SetRowData(response);                                                                        
                    }
                },
                complete: function () {
                    BlockUI.UnBlockElement("dialog");
                }
            });
        });

        $.validator.addMethod('validNumber', function (value, element) {
            var floatRegex = '[-+]?([0-9]*\.[0-9]+|[0-9]+)';
            return (value.match(floatRegex));
        }, 'Not accept non-numeric');
        $("#dialogForm").validate({
            rules: {
                StartRange: {
                    validNumber: true
                },
                EndRange: {
                    validNumber: true
                }
            }
        });
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
            <form id="dialogForm">
            <input type="hidden" id="Id" value="<%=Model.Id %>" />
            <fieldset class="register">
                <legend>SSS Details</legend>
                <p>
                    <label for="StartRange">Start Range:</label>
                    <input type="text" id="StartRange" name="StartRange" class="textEntry" value="<%=Model.StartRange %>"  />
                </p>
                <p>
                    <label for="EndRange">End Range:</label>
                    <input type="text" id="EndRange" name="EndRange" class="textEntry" value="<%=Model.EndRange %>" />
                </p>
            </fieldset>
            <p class="submitButton">
                <input type="button" id="SSSSubmitButton" value="OK" />
            </p>
            </form>
</asp:Content>